// if (!localStorage.save) window.location.href = 'index.html';

var save = {
	ver : '0001',
	formLogin : {
		'username' : '',
	},
	rulesLogin : {
			// { type: 'number', message: '年龄必须为数字值'}
		username: [
			{ required: true, message: '请输入用户名', trigger: 'blur' },
		],
		password: [
			{ required: true, message: '请输入密码', trigger: 'blur' },
		],
	},
};

var index = new Vue({
	el: '#lord',
	data: save,
	methods: {
// 消息提示
		alertInfo : function(message) {
			this.$message({
				showClose: true,
				message: message
			});
		},

		alertSuccess : function(message) {
			this.$message({
				showClose: true,
				message: message,
				type : 'success',
			});
		},

		alertWarning : function(message) {
			this.$message({
				showClose: true,
				message : message,
				type : 'warning',
			});
		},

		alertDanger : function(message) {
			this.$message({
				showClose: true,
				message : message,
				type : 'danger',
			});
		},

        submitLoginForm : function() {
            axios({
                method: 'post',
                url: '?o=login',
                headers: {
                    'X-Requested-With': 'XMLHttpRequest',
                    'Content-Type': 'application/x-www-form-urlencoded'
                },
                data: "username=" + save.formLogin.username +"&password=" + save.formLogin.password
            })
                .then(function(response) {
                    result = JSON.parse(response.request.response);

                    if (result.Status != 101) {
                        index.alertWarning(result.Message);
                    } else {
                        window.location.href = 'lords.html';
                    }
                });
        },
	},

	computed: {
		manorTable : function() {
			return 0;
		}
	},

	mounted: function () {
		/*this.$nextTick(function () {
			if (!localStorage.save) {
				window.location.href = 'index.html';
				this.alertWarning('异常：无法完成初始化！')
			}
		})*/
	}
})